
#ifndef RSIM_H
#define RSIM_H

#include <QMainWindow>
#include <QMap>
class QRoundabout;
class QLabel;
class QHBoxLayout;
class QComboBox;
class QSpinBox;
class QSplitter;
class QGroupBox;
class QVBoxLayout;
class QScrollArea;
class QPushButton;
class QSpacerItem;
class Options;
class IntensityTraffic;
class RightSideRules;
class IntensityPedestrian;
class Branch;

class RSim : public QMainWindow
{
    Q_OBJECT

public:
    RSim(QWidget *parent = 0);
    ~RSim();

private:
    QRoundabout *_qroundabout;
    QMenu *Opcje;

    QAction *carAct;
    QAction *toggleIntensityOptionsAction;
    QAction *toggleRightOptionsAction;
    QAction *clearConfigurationFilesAction;
    QAction *saveSettingsAsAction;
    QAction *loadSettingsAction;

    QWidget *centralWidget;
    QWidget *rightSideWidget;
    QWidget *leftSideWidget;

    QHBoxLayout* mainlayout;
    QHBoxLayout* buttonsTimersLayout;
    QHBoxLayout* buttonsGlobalIntensityLayout;
    QVBoxLayout* leftSideLayout;
    QHBoxLayout* trafficLayout;
    QVBoxLayout* rightSideLayout;
    QVBoxLayout *mainLayout;

    QTimer* timer;
    QTimer* carTimer;

    QLabel *carCountLabel;
    QLabel *backupLabel;
    QLabel *globalIntensityLabel;

    QPushButton *cmdPlayPause;
    QPushButton *cmdStop;
    QPushButton *cmdTimer;
    QPushButton *cmdStopAdding;
    QPushButton *cmdTimedSimulation;

    QSpinBox *spGlobalIntensity; // globalne natężenie generowania samochodów
    QSplitter *splitter;
    QGroupBox *trafficGroupBox;
    QGroupBox *rightSide;

    QWidget *wyimaginowanyWidget;
    QScrollArea *scrollArea;
    Options *options;
    IntensityTraffic *traffic;
    RightSideRules *rulesWidget;
    IntensityPedestrian *pedestrianWidget;
    QSpacerItem *optionSpacer;
    QString stylesheet;

    int time;
    int carTimerTimeout;
    QList<int> rulesDistribution; // 0 - official, 1 - matchingLanes, 2 - invertedPriority
    int carsThatMayLeaveRoundabout, carsDestroyed;
    int numberOfTimesThatGeneratorMayBeInvoked;

    void generateCar(int source);
    void generatePedestrian(int source);
    void readSettings(QString name = "RoundaboutSimulator");
    void createWidgets();
    void configureWidgets();

private slots:
    void showOptions();
    void generator();
    void playPause();
    void stopAdding();
    void carsStop();
    void carDestroyed();
    void readTrafficSettings(QString name = "RoundaboutSimulator");
    void toggleIntensityOptionsSlot();
    void toggleRightOptionsSlot();
    void clearConfigurationFiles();
    void readRulesSettings(QString name = "RoundaboutSimulator");
    void readPedestrianSettings(QString name = "RoundaboutSimulator");
    void saveSettingsAs();
    void loadSettings();
    void saveAllSettings(QString name = "RoundaboutSimulator");
    void readAllSettings(QString name = "RoundaboutSimulator");
    void on_cmdTimedSimulation_clicked();

    void debug(QString);
};

#endif // RSIM_H
